import time

from autoframe.common.base import Base, By


class LoginPage(Base):
    # 用户名
    def input_username(self, username):
        self.find_element((By.NAME, 'username')).send_keys(username)

    # 输入密码
    def input_password(self, password):
        self.find_element((By.NAME, 'password')).send_keys(password)

    # 点击保存登录信息
    def remember(self):
        self.find_element((By.ID, 'remember')).click()

    # 点击登录
    def btn_login(self):
        self.find_element((By.CLASS_NAME, 'loginbtn')).click()


if __name__ == '__main__':
    login = LoginPage('chrome')
    login.get('https://ecshop.test2.shopex123.com/user.php')
    login.input_username('aaabbb')
    login.input_password('123456')
    login.remember()
    login.btn_login()
    time.sleep(2)
    login.quit()
